package com.choosefine.base.attendance.client.staff;
import com.choosefine.base.common.model.ReturnResult
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

/*
*
* gen by 邱鹏 mapper 2017-08-29
*/
@Service
open class AttendanceStaffService{
val log: Logger = LoggerFactory.getLogger(AttendanceStaffService::class.java)
@Autowired lateinit var attendanceStaffDao: AttendanceStaffDao

fun getAttendanceStaffList(attendanceStaff: AttendanceStaff): ReturnResult {
    var attendanceStaffList: List<AttendanceStaff>
    attendanceStaffList = attendanceStaffDao.findAttendanceStaffList(attendanceStaff)//查找某个节点对应的直系子女
    var result = ReturnResult(200, "获取数据成功", attendanceStaffList)
    return result
  }

fun updateAttendanceStaff(attendanceStaff: AttendanceStaff): ReturnResult {
    var returnResult = ReturnResult()
    returnResult.status = 200
    try {
        attendanceStaffDao.updateById(attendanceStaff)
        returnResult.message = "update  AttendanceStaff成功"
    } catch (ex: Exception) {
        log.error(ex.message)
        returnResult.status = 500
        throw RuntimeException("更新AttendanceStaff出错X_X")
    } finally {
        return returnResult
    }
}

fun createAttendanceStaff(attendanceStaff: AttendanceStaff): ReturnResult {
    var returnResult = ReturnResult()
    returnResult.status = 200
    try {
        attendanceStaffDao.insert(attendanceStaff)
        returnResult.message = "新增attendanceStaff成功"
    } catch (ex: Exception) {
        log.error(ex.message)
        returnResult.status = 500
        throw RuntimeException("新增资源出错X_X")
    } finally {
        return returnResult
    }
}
}
